home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Printer Drivers… / ImageWriter--DTP renamer / OldApp.c < prev    next >
Encoding:
Text File  |  1995-04-10  |  18.2 KB  |  663 lines  |  [TEXT/MPS ]

  1. /*
  2.     copyright © 1992-1994 Apple Computer Inc.  All rights reserved.
  3.     
  4.     OldApp.c
  5.     This file implements old application message overrides for the specific driver.
  6.     
  7.     Included in this file is the old PrintRecord emulation.  Note that the ImageWriter
  8.     PrintRecord is a wonder of misdirection and special cases.  You'll have fun
  9.     figuring out the code - so unless you really want to exactly emulate the ImageWriter
  10.     pages, you shouldn't spend too much time looking at this code.
  11.     
  12.     Modification history
  13.     7/23/92            TED            New file today
  14.     12/20/93        dmh            Sync'd with the shipping 1.0b3 GX driver.
  15.      6/23/94        dmh            Added overrides for renaming DTPs.
  16.      8/26/94        dmh            Sync'd with the shipping 1.0.1 GX driver.
  17.  
  18. */
  19.  
  20. // Include the standard Mac header files 
  21. #include <Errors.h>
  22. #include <ToolUtils.h>
  23. #include <StdIO.h>
  24. #include <StdLib.h>
  25. #include <String.h>
  26. #include <Strings.h>
  27. #include <Resources.h>
  28. #include <ToolUtils.h>
  29. #include <OSUtils.h>
  30. #include <Files.h>
  31. #include <Types.h>
  32. #include <Packages.h>
  33. #include <Memory.h>
  34. #include <Serial.h>
  35. #include <Devices.h>
  36. #include <Fonts.h>
  37. #include <Printing.h>
  38. #include <Script.h>
  39. #include <Events.h>
  40. #include <Dialogs.h>
  41. #include <FixMath.h>
  42. #include <Lists.h>
  43. #include <AppleTalk.h>
  44. #include <Menus.h>
  45. #include <Events.h>
  46. #include <Balloons.h>
  47. #include <Folders.h>
  48. #include <SCSI.h>
  49.  
  50. // Include the new QuickDraw GX graphics header files 
  51. #include <graphics routines.h>
  52. #include <graphics libraries.h>
  53. #include <math routines.h>
  54. #include <qd library.h>
  55. #include <font library.h>
  56. #include <layout routines.h>
  57. #include <graphics libraries.h>
  58.  
  59. // Include the required Printing Manager header files 
  60. #include <PrintingManager.h>
  61. #include <PrintingMessages.h>
  62. #include <PrintingDrivers.h>
  63. #include <Collections.h>
  64. #include <Messages.h>
  65. #include <PrintingResTypes.h>
  66. #include <PrintingErrors.h>
  67. #include <PrintingLibraries.h>
  68.  
  69. #include <GXExceptions.h>
  70.  
  71. #include "CommonDefines.h"            // things common to .r and .h files
  72.  
  73. /* ----------------------------------------------------------------------------    */
  74. /* INTERNAL TYPEDEFS AND STRUCTURES                                                */
  75. /* ----------------------------------------------------------------------------    */
  76. // ImageWriter wDev values
  77. #define kBest            0x01
  78. #define kPortrait        0x02
  79. #define kTallAdjusted    0x04
  80. #define k50Percent        0x08
  81. #define kNoGaps            0x10
  82. #define kSetResCalled    0x20
  83.  
  84. // some ImageWriter constants
  85. #define kGapSize        60        // gap at top of page in 120ths of an inch
  86. #define kSmallPlaten    16        // platen width in half inches for small IW
  87. #define kBigPlaten        27        // platen width in half inches for the 15" IW
  88.  
  89. /* ----------------------------------------------------------------------------    */
  90. /* FORWARD DECLARES                                                                */
  91. /* ----------------------------------------------------------------------------    */
  92. OSErr SD_ConvertPrintRecordTo(THPrint hoPrint);
  93. OSErr SD_ConvertPrintRecordFrom(gxUniversalPrintRecordHdl huPrint);
  94.  
  95.  
  96. /* ----------------------------------------------------------------------------    */
  97. /* INTERNAL ROUTINES                                                            */
  98. /* ----------------------------------------------------------------------------    */
  99. OSErr    UpdatePrintRecord(THPrint hPrint)
  100. {
  101.     OSErr                        anErr;
  102.     gxUniversalPrintRecordHdl     huPrint = hPrint;
  103.     gxUniversalPrintRecordPtr     puPrint;
  104.     short                        devVRes, devHRes, appVRes, appHRes;
  105.     short                        cPlaten;
  106.     
  107.     // convert to universal format
  108.     anErr = SD_ConvertPrintRecordTo(hPrint);
  109.     if (anErr == noErr)
  110.         {
  111.         // determine application & device resolutions, based upon quality mode, tall adjusted
  112.         // setting, and if the app called SetRsl:
  113.         //    draft - 80(h)*72(v)
  114.         //    faster - 80(h)*72(v)
  115.         //    best - 160(h)*144(v)
  116.         //
  117.         //    draft (tall adjusted) - 72*72
  118.         //    faster (tall adjusted) - 72*72
  119.         //    best (tall adjusted) - 144*144
  120.         
  121.         puPrint = *huPrint;
  122.         if (puPrint->options & gxPreciseBitmap)
  123.             switch(puPrint->qualityMode)
  124.                 {
  125.                 case gxDraftQuality:
  126.                 case gxFasterQuality:
  127.                     devVRes = devHRes = 72;
  128.                     appVRes = appHRes = 72;
  129.                     break;
  130.                     
  131.                 case gxBestQuality:
  132.                     devVRes = devHRes = 144;
  133.                     appVRes = appHRes = 72;
  134.                     break;
  135.                 }
  136.         else
  137.             switch(puPrint->qualityMode)
  138.                 {
  139.                 case gxDraftQuality:
  140.                 case gxFasterQuality:
  141.                     appVRes = devVRes = 72;
  142.                     appHRes = devHRes = 80;
  143.                     break;
  144.                     
  145.                 case gxBestQuality:
  146.                     devVRes = 144;
  147.                     devHRes = 160;
  148.                     appVRes = 72;
  149.                     appHRes = 80;
  150.                     break;
  151.                 }
  152.             
  153.         // SetRsl was called?  Use the resolution specified by the application
  154.         if (puPrint->appVRes != 72)
  155.             {
  156.             appVRes = devVRes = puPrint->appVRes;
  157.             appHRes = devHRes = puPrint->appHRes;
  158.             }
  159.             
  160.         // finally, store the app & device resolutions
  161.         puPrint->devVRes = devVRes;
  162.         puPrint->devHRes = devHRes;
  163.         puPrint->appVRes = appVRes;
  164.         puPrint->appHRes = appHRes;
  165.         
  166.         // here we do page size calculations
  167.         // Please note that this code is confusing - it's purpose is to emulate
  168.         // the existing ImageWriter driver's page size.  Most drivers would not
  169.         // do this - the existing in the system probably is good enough.
  170.         {
  171.         long        pageGap;                // gap at top of page
  172.         long        dvPaper, dhPaper;        // paper size at device res
  173.         long        dvPage, dhPage;            // page size at device res
  174.         long        scanLines, scanBits;    // # of scan lines or bits on page
  175.         long        maxH;                    // maximum width
  176.         long        hOff, vOff;                // margins (horiz & vert) to get paper rect from page rect
  177.         
  178.         // gap at the top of the page in pixels
  179.         pageGap = (kGapSize * appVRes) / 120;
  180.         if (puPrint->options & gxBiggerPages)
  181.             pageGap = 0;
  182.             
  183.         // figure out paper size in application space pixels
  184.         dvPaper = (puPrint->pageV * appVRes) / 120;
  185.         dhPaper = (puPrint->pageH * appHRes) / 120;
  186.                 
  187.         // vertically, align to the head height of 8 pixels
  188.         scanLines = ((dvPaper - pageGap) >> 3) << 3;
  189.         
  190.         // horizontally, allow the biggest width we can handle
  191.         cPlaten = kSmallPlaten;
  192.         if (puPrint->pageH > (9*120) )
  193.             cPlaten = kBigPlaten;
  194.             
  195.         maxH = (cPlaten * appHRes) >> 1;
  196.         if (maxH > dhPaper)
  197.             maxH = dhPaper;
  198.         scanBits = (maxH >> 4) << 4;
  199.         
  200.         if (puPrint->orientation == gxPortraitOrientation)
  201.             {
  202.             // portrait
  203.             
  204.             dhPage = scanBits;
  205.             dvPage = scanLines;
  206.             
  207.             hOff = (dhPage - dhPaper) >> 1;
  208.             vOff = -pageGap;
  209.             }
  210.         else
  211.             {
  212.             // landscape
  213.             
  214.             dhPage = scanLines;
  215.             dvPage = scanBits;
  216.             
  217.             // reverse the paper definition as well
  218.             {
  219.             long iTemp = dhPaper;
  220.             dhPaper = dvPaper;
  221.             dvPaper = iTemp;
  222.             }
  223.             
  224.             hOff = -pageGap;
  225.             vOff = (dvPage - dvPaper) >> 1;
  226.             }
  227.             
  228.         // 50% reduction?  scale everything by 2X
  229.         if (puPrint->options & gxUserFlag0)
  230.             {
  231.             dhPage <<= 1;
  232.             dvPage <<= 1;
  233.             dhPaper <<= 1;
  234.             dvPaper <<= 1;
  235.             hOff <<= 1;
  236.             vOff <<= 1;
  237.             }
  238.             
  239.         // set the page and paper in app space
  240.         puPrint->appPage.left         = puPrint->appPage.top = 0;
  241.         puPrint->appPage.right         = dhPage;
  242.         puPrint->appPage.bottom     = dvPage;
  243.         
  244.         puPrint->appPaper.left         = hOff;
  245.         puPrint->appPaper.top         = vOff;
  246.         puPrint->appPaper.right     = dhPaper + hOff;
  247.         puPrint->appPaper.bottom     = dvPaper + vOff;
  248.                 
  249.         // from page, scale up to device space (in case some weenie decides to look at that)
  250.         puPrint->devPage.left         = puPrint->devPage.top = 0;
  251.         puPrint->devPage.right         = dhPage * devHRes / appHRes;
  252.         puPrint->devPage.bottom     = dvPage * devVRes / appVRes;
  253.         }
  254.         
  255.         // convert back to non-universal format
  256.         anErr = SD_ConvertPrintRecordFrom((gxUniversalPrintRecordHdl) hPrint);
  257.         }
  258.         
  259.     return(anErr);
  260.     
  261. } // UpdatePrintRecord
  262.  
  263. //<FF>
  264. /* ----------------------------------------------------------------------------    */
  265. /* MESSAGE OVERRIDES                                                            */
  266. /* ----------------------------------------------------------------------------    */
  267. OSErr SD_ConvertPrintRecordTo(THPrint hoPrint)
  268. /*
  269.     This call takes a print record in old style (driver specific) format, and
  270.     converts it to the format of "gxUniversalPrintRecordHdl"
  271. */
  272. {
  273.     TPPrint                        poPrint;            // pointer to old style print record
  274.     gxUniversalPrintRecordHdl    huPrint = hoPrint;    // handle to universal print record
  275.     gxUniversalPrintRecordPtr    puPrint;            // pointer to universal print record
  276.     short                        qualityMode;        // cached quality mode
  277.     short                        wDev;                // cached wDev
  278.     
  279.     // cache pointers for size and speed
  280.     puPrint = *huPrint;
  281.     poPrint = *hoPrint;
  282.     wDev = poPrint->prStl.wDev;
  283.     
  284.     // determine quality mode
  285.     if (poPrint->prJob.bJDocLoop == 0)
  286.         qualityMode = gxDraftQuality;
  287.     else
  288.         {
  289.         if (wDev & kBest)
  290.             qualityMode = gxBestQuality;
  291.         else
  292.             qualityMode = gxFasterQuality;
  293.         }
  294.         
  295.     // universal feed is the inverse of our feed
  296.     puPrint->feed            =    1-(poPrint->prStl.feed);
  297.     
  298.     // wDev 0x02 means portrait, else landscape
  299.     if (wDev & kPortrait) 
  300.         puPrint->orientation    =    gxPortraitOrientation;
  301.     else
  302.         {
  303.         puPrint->orientation    =    gxLandscapeOrientation;
  304.         
  305.         // landscape disabled draft, forces tall adjusted
  306.         if (qualityMode == gxDraftQuality)
  307.             qualityMode = gxFasterQuality;
  308.         wDev |= kTallAdjusted;
  309.         }
  310.         
  311.     // copies are in iCopies field (wow.)
  312.     puPrint->actualCopies        =    poPrint->prJob.iCopies;
  313.     
  314.     // store our flags
  315.     puPrint->options = 0;
  316.     
  317.     // tall adjusted
  318.     if (wDev & kTallAdjusted) 
  319.         puPrint->options |= gxPreciseBitmap;
  320.         
  321.     // 50% reduction
  322.     if (wDev & k50Percent) 
  323.         {
  324.         puPrint->options |= gxUserFlag0;
  325.         puPrint->reduction = 50;
  326.         
  327.         // for 50% reduction, we always return faster to the application
  328.         qualityMode = gxFasterQuality;
  329.         }
  330.     else
  331.         puPrint->reduction = 100;
  332.         
  333.     // no gaps
  334.     if (wDev & kNoGaps) 
  335.         puPrint->options |= gxBiggerPages;
  336.     
  337.     // finally, store quality mode    
  338.     puPrint->qualityMode = qualityMode;
  339.     
  340.     // and we can't have any errors - because this code is too godlike.
  341.     return(noErr);
  342.     
  343. } // SD_ConvertPrintRecordTo
  344.  
  345. //<FF>
  346. /* ----------------------------------------------------------------------------    */
  347. OSErr SD_ConvertPrintRecordFrom(gxUniversalPrintRecordHdl huPrint)
  348. /*
  349.     This call takes a print record in universal format and converts it
  350.     to old style (driver specific) format.
  351.     
  352.     Note: for the ImageWriter, I'm filling in way more things than theoretically
  353.     I need to.  However, since the ImageWriter is one of the oldest print drivers,
  354.     there is much more of a chance that someone assumes something about one or
  355.     more of the fields.
  356. */
  357. {
  358.     gxUniversalPrintRecordPtr    puPrint;            // pointer to universal print record
  359.     THPrint                        hoPrint = huPrint;    // handle to old style print record
  360.     TPPrint                        poPrint;            // pointer to old style print record
  361.     short                        options;            // cached universal options
  362.     short                        qualityMode;        // cached universal quality mode
  363.     short                        actualCopies;        // cached universal copies
  364.     
  365.     // cache pointers for size and speed
  366.     puPrint = *huPrint;
  367.     poPrint = *hoPrint;
  368.  
  369.     // save away fields within the universal record that we'll be stomping over
  370.     // as we convert
  371.     options         = puPrint->options;
  372.     qualityMode     = puPrint->qualityMode;
  373.     actualCopies    = puPrint->actualCopies;
  374.     
  375.     poPrint->iPrVersion            = 4;        // used to be 3, but this is
  376.                                             // a new driver.  We support versions
  377.                                             // 3 and 4
  378.     poPrint->prInfo.iDev        = 0;        // always zero for the ImageWriter
  379.     
  380.     // skip remaining fields in prInfo because they are unchanged
  381.     
  382.     // determine the wDev
  383.     {
  384.     short    wDev;
  385.     
  386.     // this is the wDev value for the ImageWriter
  387.     wDev = 0x0100;
  388.     
  389.     if (puPrint->orientation == gxPortraitOrientation)
  390.         wDev |= kPortrait;
  391.     else
  392.         {
  393.         // for landscape, disable draft and force tall adjusted
  394.         if (qualityMode == gxDraftQuality)
  395.             qualityMode = gxFasterQuality;
  396.             
  397.         options |= gxPreciseBitmap;
  398.         }
  399.     
  400.     // user options
  401.     if (options & gxPreciseBitmap)
  402.         wDev |= kTallAdjusted;
  403.     if (options & gxUserFlag0)
  404.         {
  405.         wDev |= k50Percent;
  406.         qualityMode = gxFasterQuality;
  407.         }
  408.  
  409.     if (options & gxBiggerPages)
  410.         wDev |= kNoGaps;
  411.         
  412.     // if the application's resolution isn't 72 - then clearly SetRsl must have been called
  413.     // to change it.
  414.     if (poPrint->prInfo.iVRes != 72)
  415.         {
  416.         wDev |= kSetResCalled;
  417.         qualityMode == gxBestQuality;
  418.         }
  419.         
  420.     if (qualityMode == gxBestQuality)
  421.         wDev |= kBest;
  422.         
  423.         
  424.     // and finally, save away that short value we worked so hard to determine
  425.     poPrint->prStl.wDev = wDev;
  426.     }
  427.  
  428.     // other fields in prStl remain the same
  429.     
  430.     poPrint->prStl.bPort     = 0;
  431.     poPrint->prStl.feed     = 1 - (puPrint->feed);
  432.     poPrint->prInfoPT.iDev     = (qualityMode == gxBestQuality) ? -768 : 0;
  433.  
  434.     // other fields in prInfoPT remain the same
  435.     {
  436.     Rect    rPage = poPrint->prInfoPT.rPage;
  437.     
  438.     // calculate some fields we don't use - in case someone really wants to look at
  439.     // them for some reason
  440.     poPrint->prXInfo.iRowBytes    = rPage.right >> 3;
  441.     poPrint->prXInfo.iBandV        = 32;
  442.     poPrint->prXInfo.iBandH        = poPrint->prXInfo.iRowBytes << 3;
  443.     poPrint->prXInfo.iDevBytes    = poPrint->prXInfo.iRowBytes * 
  444.                                     poPrint->prXInfo.iBandV + 
  445.                                     poPrint->prXInfo.iBandH;
  446.     poPrint->prXInfo.iBands        = (rPage.bottom+(poPrint->prXInfo.iBandV-1)) / poPrint->prXInfo.iBandV;
  447.     poPrint->prXInfo.bPatScale     = (qualityMode == gxBestQuality) ? -2 : 0;
  448.     poPrint->prXInfo.bUlThick     = 1;
  449.     poPrint->prXInfo.bUlOffset     = 1;
  450.     poPrint->prXInfo.bUlShadow     = 1;
  451.     poPrint->prXInfo.scan        = (poPrint->prStl.wDev & kPortrait) ? 0 : 2;
  452.     poPrint->prXInfo.bXInfoX    = 0;
  453.     }
  454.     
  455.     // other fields in prJob remain the same
  456.     poPrint->prJob.iCopies        = actualCopies;
  457.     poPrint->prJob.bJDocLoop    = (qualityMode == gxDraftQuality) ? 0 : 1;
  458.     
  459.     // this routine is so studly, there can be no errors
  460.     return(noErr);    
  461.     
  462. } // SD_ConvertPrintRecordFrom
  463.  
  464.  
  465. //<FF>
  466. /* ----------------------------------------------------------------------------    */
  467. OSErr SD_PrintRecordToJob(THPrint hPrint, gxJob theJob)
  468. /*
  469.     We convert the "tall adjusted" setting into the correct rendering option for
  470.     the job collection.
  471. */
  472. {
  473.     OSErr    anErr;
  474.     Handle     jobQualitySettingsHdl;    
  475.     
  476.     anErr = Forward_GXPrintRecordToJob(hPrint, theJob);
  477.     if (anErr == noErr)
  478.         {
  479.         long imagewriterOptions = kSuperRes;
  480.         
  481.         if ((**hPrint).prStl.wDev & kSetResCalled)
  482.             {
  483.             Collection            jobCollection = GXGetJobCollection(GXGetJob());
  484.             gxQualityInfo        *qualitySettings;
  485.     
  486.  
  487.             // get old info and replace it with final quality
  488.  
  489.  
  490.             jobQualitySettingsHdl = NewHandle(0);
  491.             anErr = MemError();
  492.             nrequire(anErr, FailedNewHandle);
  493.  
  494.             anErr = GetCollectionItemHdl (     jobCollection,
  495.                                                 gxQualityTag,
  496.                                                  gxPrintingTagID,
  497.                                                jobQualitySettingsHdl );
  498.  
  499.             if (anErr == collectionItemNotFoundErr) 
  500.                 {
  501.                 Str255            bestString, roughString;
  502.                 Size            count1, count2;
  503.                 Ptr                p;
  504.                 short            curResFile = CurResFile();
  505.                 
  506.                 UseResFile(GXGetMessageHandlerResFile());
  507.                 GetIndString( bestString, kOldQualityID, kBestString);
  508.                 GetIndString( roughString, kOldQualityID, kRoughString);
  509.                 UseResFile(curResFile);
  510.  
  511.                 SetHandleSize(jobQualitySettingsHdl,(sizeof(gxQualityInfo) + bestString[0] + roughString[0] + 2 ));
  512.                 anErr = MemError();
  513.                 nrequire( anErr, FailedSetHandleSize );
  514.                         
  515.                 qualitySettings = *((gxQualityInfo **) jobQualitySettingsHdl);
  516.                 
  517.                 qualitySettings->disableQuality = false;
  518.                 qualitySettings->defaultQuality = 1;
  519.                 qualitySettings->currentQuality = 1;
  520.                 qualitySettings->qualityCount = 2;
  521.         
  522.                 count1 = bestString[0]+1;
  523.                 p = qualitySettings->qualityNames;
  524.                 BlockMove( bestString, p, count1 );
  525.         
  526.                 count2 = roughString[0]+1;
  527.                 p += count1;
  528.                 BlockMove( roughString, p, count2 );
  529.         
  530.                 }
  531.             else
  532.                 qualitySettings = *((gxQualityInfo **) jobQualitySettingsHdl);
  533.  
  534.             (qualitySettings->currentQuality = qualitySettings->qualityCount-1);
  535.  
  536.             anErr = AddCollectionItemHdl (     jobCollection,
  537.                                             gxQualityTag,
  538.                                             gxPrintingTagID,
  539.                                             jobQualitySettingsHdl );
  540.                                                  
  541.             if (anErr == noErr)
  542.                 (void) SetCollectionItemInfo(jobCollection, gxQualityTag, gxPrintingTagID, 0x0000FFFF, gxVolatileOutputDriverCategory);
  543.                 
  544.             DisposHandle(jobQualitySettingsHdl);
  545.             }
  546.  
  547.         if ((**hPrint).prStl.wDev & kTallAdjusted)
  548.             imagewriterOptions = 0;
  549.             
  550.         if (anErr == noErr)
  551.             anErr = AddCollectionItem(GXGetJobCollection(theJob), 
  552.                         DriverCreator,
  553.                         0,
  554.                         sizeof(imagewriterOptions),
  555.                         &imagewriterOptions);
  556.         }
  557.  
  558. FailedNewHandle:        
  559.     return(anErr);
  560.  
  561. FailedSetHandleSize:
  562.     DisposHandle(jobQualitySettingsHdl);
  563.     return(anErr);
  564.     
  565. } // SD_PrintRecordToJob
  566.  
  567. //<FF>
  568. /* ----------------------------------------------------------------------------    */
  569. OSErr SD_PrValidate(    THPrint hPrint,                 // old style print record
  570.                         Boolean *wasChanged)            // was the print record changed?
  571. /*
  572.     This call validates the current print record.  It's fairly simplistic (as were
  573.     all of the old drivers) - the wDev or versions don't match the current, we call
  574.     PrintDefault.  Otherwise, we call UpdatePrintRecord - to allow the driver to sanity
  575.     check any internal fields.
  576.     
  577. */
  578. {
  579.     unsigned short    wDev;                        // note: if this were signed, the shift below would fail                    
  580.     Boolean            recordIsInvalid = true;            
  581.     OSErr            anErr = noErr;
  582.     
  583.     // check the wDev.  The upper byte must be equal to our idea of the wDev
  584.         
  585.     wDev =  (**hPrint).prStl.wDev;    
  586.     wDev >>= 8;                                // get just the device ID
  587.  
  588.     // If the device id is equal, then check the version number of the print record.
  589.     //    Only if that is also equal to the current version, will we return false (valid).
  590.         
  591.     if (     (wDev == 1) 
  592.         &&
  593.             (
  594.             ( ((**hPrint).iPrVersion) == 3 ) ||
  595.             ( ((**hPrint).iPrVersion) == 4 ) 
  596.             )
  597.         )
  598.         recordIsInvalid = false;
  599.             
  600.  
  601.     // If the the print record is not valid, then return the default print record.
  602.     // Otherwise, update the print record, based on the application's calls
  603.     // to PrGeneral.
  604.         
  605.     if (recordIsInvalid)
  606.         PrintDefault(hPrint);
  607.     else
  608.         anErr = UpdatePrintRecord(hPrint);
  609.         
  610.     *wasChanged = recordIsInvalid;
  611.     
  612.     return (anErr);
  613.     
  614. } // SD_PrValidate
  615.  
  616. //<FF>
  617. /* ----------------------------------------------------------------------------    */
  618. OSErr SD_PrJobInit(THPrint hPrint, TPPrDlg * pDlg)
  619. /*
  620.     This routine is called to initialize the job dialog.  We take the default
  621.     behavior - and then disable some of the items based on settings the user
  622.     has made:
  623.         - 50% disables all items
  624.         - apps that call SetRsl disable all items
  625.         - landscape disables draft mode
  626. */
  627. {
  628.     OSErr    anErr;
  629.     
  630.     anErr = Forward_GXPrJobInit(hPrint, pDlg);
  631.     if (anErr == noErr)
  632.         {
  633.         Boolean    disableDraft     = false;
  634.         Boolean    disableAll         = false;
  635.         short    wDev             = (**hPrint).prStl.wDev;
  636.         short    idx;
  637.         Rect    box;
  638.         Handle    item;
  639.         short    type;
  640.         
  641.         if (wDev & k50Percent)
  642.             disableAll = true;
  643.             
  644.         if (wDev & kSetResCalled)
  645.             disableAll = true;
  646.             
  647.         if (!(wDev & kPortrait))
  648.             disableDraft = true;
  649.         
  650.         // disable any controls we need to
  651.         for (idx = 6; idx <= 8; ++idx)
  652.             {
  653.             GetDItem((DialogPtr) *pDlg, idx, &type, &item, &box);
  654.             
  655.             if ( (disableAll) || ((disableDraft) && (idx == 8) ) )
  656.                 HiliteControl((ControlHandle) item, 255);
  657.             
  658.             }
  659.         }
  660.  
  661.     return(anErr);
  662.     
  663. } // SD_PrJobInit